import {
	MPickupViewActionType,
	IMPickupViewAbility,
	IMPickupViewControllerParams,
	IMPickupViewModel,
	IMPickupViewStore,
	IParam,
	IViewEvent,
} from '@/core';
import { QXEvent } from 'qx-util';
import {
	getViewClassNames,
	useViewAction,
	useViewBasic,
	useViewControllerParams,
    handlePickupViewButtonAction, 
    handleMPickupViewPickButtonAction, 
    handleMPickupViewAction,
	useViewProps,
} from '../use-view';

/**
 * 获取数据多项选择视图输入参数
 *
 * @export
 * @return {*}
 */
export function useMPickupViewProps() {
	return {
		...useViewProps(),
	};
}

/**
 * 获取数据多项选择视图基础
 *
 * @export
 * @param {IMPickupViewModel} model 数据多项选择视图模型
 * @param {IParam} props 输入参数
 * @return {*}
 */
export function useMPickupViewBasic(model: IMPickupViewModel,props: IParam) {
	const getClassNames = (props:IParam) =>{
		return getViewClassNames(model, props)
	}
	return {
		...useViewBasic(model,props),
		getClassNames,
        handlePickupViewButtonAction, 
        handleMPickupViewPickButtonAction,
        handleMPickupViewAction,
	};
}

/**
 * 数据多项选择视图行为
 *
 * @export
 */
export function useMPickupViewAction(controller: any) {
    const getPanelItemClass = (item: IParam) => {
        return {
            'picker-item': true,
            'is-active': controller.store.panelSelectedKeys.indexOf(item.srfkey) !== -1
        }
    }
	return {
		...useViewAction(controller),
        getPanelItemClass
	};
}

/**
 * 获取数据多项选择视图控制器输入参数
 *
 * @export
 * @param {IMPickupViewModel} model
 * @param {IParam} props
 * @param {QXEvent<IViewEvent<MPickupViewActionType, IMPickupViewAbility>>} evt
 * @return {*}  {IMPickupViewControllerParams<MPickupViewActionType, IMPickupViewAbility>}
 */
export function useMPickupViewControllerParams(
	model: IMPickupViewModel,
	props: IParam,
	evt: QXEvent<IViewEvent<MPickupViewActionType, IMPickupViewAbility>>
): IMPickupViewControllerParams<MPickupViewActionType, IMPickupViewAbility> {
	return {
		...useViewControllerParams<IMPickupViewStore, IMPickupViewModel>(
			model,
			props,
			evt
		),
	};
}
